package leetcode_day._2022._202202._2128;

/**
 * @author yzh
 * @version 1.0
 * @date 2022/2/28 20:34
 * 复数乘法
 * 算法：模拟
 */
public class _25_537 {
    public static void main(String[] args) {
        String s = "1+1i";
        System.out.println(s.substring(s.indexOf("+") + 1, s.length() - 1));
    }

    public String complexNumberMultiply(String num1, String num2) {
        int a1 = Integer.parseInt(num1.substring(0, num1.indexOf("+")));
        int b1 = Integer.parseInt(num1.substring(num1.indexOf("+") + 1, num1.length() - 1));
        int a2 = Integer.parseInt(num2.substring(0, num2.indexOf("+")));
        int b2 = Integer.parseInt(num2.substring(num2.indexOf("+") + 1, num2.length() - 1));
        int l = a1 * a2 - b1 * b2, r = a1 * b2 + b1 * a2;
        return l + "+" + r + "i";
    }

}
